package com.dq.domain.activity;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.org.Org;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

/**
 * @author liuhui
 * @date 2019/11/20 0020 15:38:16
 */
@Data
@Entity
@ApiModel("活动参与记录")
public class ActivityRecord extends BaseEntity implements VO.ToVO {

    @ApiModelProperty("用户")
    @ManyToOne
    protected SysUser sysUser;

    @ApiModelProperty("活动")
    @ManyToOne
    protected Activity activity;

    @ApiModelProperty("用户所属门店，ps：用门店检索")
    @ManyToOne
    protected Org sysDept;




    @Data
    @ApiModel(value = "活动视图")
    public static class Vo implements VO {

    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        return vo;
    }

    @Data
    @ApiModel("用户活动视图")
    public static class UserActivityRecordVo{
        @ApiModelProperty("活动记录id")
        protected Long activityRecordId;

        @ApiModelProperty("活动标题")
        protected String title;

        @ApiModelProperty("活动描述")
        protected String description;

        @ApiModelProperty("活动开始时间")
        protected String beginTime;

        @ApiModelProperty("活动结束时间")
        protected String endTime;

        @ApiModelProperty("创建时间时间")
        protected String createTime;

        @ApiModelProperty("活动轮播地址")
        protected String bannerUrl;

        @ApiModelProperty("顾客编号")
        protected String cardNo;
        @ApiModelProperty("顾客姓名")
        protected String username;
        @ApiModelProperty("顾客手机号")
        protected String phone;
        @ApiModelProperty("活动id")
        protected Long activityId;
        @ApiModelProperty("活动参与方式文字描述")
        protected String participateDescription;
        @ApiModelProperty("活动编号")
        protected String activityNo;
    }

    public UserActivityRecordVo toUserActivityRecordVo(){
        UserActivityRecordVo vo = new UserActivityRecordVo();
        vo.activityRecordId = this.id;
        vo.title = this.activity.title;
        vo.description = this.activity.description;
        vo.beginTime = fmt(this.activity.beginTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.endTime = fmt(this.activity.endTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.createTime = fmt(this.activity.getCreateTime(), TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.bannerUrl = this.activity.bannerUrl;
        vo.activityId = this.activity.getId();
        vo.participateDescription = this.activity.getParticipateDescription();
        return vo;
    }

    public UserActivityRecordVo recordList(){
        UserActivityRecordVo vo = new UserActivityRecordVo();
        vo.activityRecordId = this.id;
        vo.activityId = this.activity.getId();
        vo.title = this.activity.title;
        vo.beginTime = fmt(this.activity.beginTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.endTime = fmt(this.activity.endTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.createTime = fmt(this.createTime,TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.cardNo = fmt(this.sysUser.getCardNo());
        vo.username = fmt(this.sysUser.getUserRealcName());
        vo.phone = fmt(this.sysUser.getUsername());
        vo.activityNo = this.activity.getActivityNo();
        return vo;
    }
}
